const Express = require('express');
const router = Express();
const { routeWrapper } = require('../../lib/module/tool/route');

const multipartyExpress = require('multiparty-express');
const fileSvc = require('../../lib/service/file');

/**
 * 通用上传文件
 */
router.post('/uploadfile', multipartyExpress.multipartyExpress(), routeWrapper(async (req, res, next) => {
    let path = await fileSvc.commonUpload(req.files.file[0]);
    await multipartyExpress.cleanup(req);
    return path;
}, false));

module.exports = {
    basePath: '/common',
    router: router
};
